using UnityEngine;

public class RoomTester : MonoBehaviour
{
    [Header("Test Configuration")]
    public RoomGenerator roomGenerator;
    public bool runTestOnStart = true;
    
    void Start()
    {
        if (runTestOnStart)
        {
            TestRoomGeneration();
        }
    }
    
    [ContextMenu("Test Room Generation")]
    public void TestRoomGeneration()
    {
        if (roomGenerator == null)
        {
            roomGenerator = GetComponent<RoomGenerator>();
        }
        
        if (roomGenerator == null)
        {
            Debug.LogError("RoomGenerator not found! Please assign a RoomGenerator component.");
            return;
        }
        
        Debug.Log("Testing RoomGenerator...");
        
        try
        {
            // 测试生成楼层
            Floor testFloor = roomGenerator.GenerateFloor(1, 1);
            
            if (testFloor != null)
            {
                int roomCount = testFloor.GetAllRooms().Count;
                Debug.Log($"Successfully generated floor with {roomCount} rooms");
                
                // 检查房间类型
                foreach (Room room in testFloor.GetAllRooms())
                {
                    Debug.Log($"Room: {room.roomType} at {room.transform.position}");
                }
                
                Debug.Log("RoomGenerator test completed successfully!");
            }
            else
            {
                Debug.LogError("Failed to generate floor!");
            }
        }
        catch (System.Exception e)
        {
            Debug.LogError($"RoomGenerator test failed: {e.Message}\n{e.StackTrace}");
        }
    }
}